package com.lzpu.thymeleafproject.demos.jobs;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 定时任务类，描述需要定时执行的具体业务逻辑
 */
public class HelloJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        //获取JobDetail对象  存放了任务相关的信息
        JobDetail jobDetail = context.getJobDetail();

        //获取JobDataMap对象
        JobDataMap jobDataMap = jobDetail.getJobDataMap();

        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");
        System.out.print(jobDataMap.get("depart") + "-----" + jobDataMap.get("username") +
                "现在时间是:" + sf.format(new Date()) + ",愉快的周末马上开始啦！-----------");
        System.out.println(Thread.currentThread().getName());
    }
}
